package com.interview.ujiuye1.controller;

import com.interview.ujiuye1.entity.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * Copyright (C), 2018-2020
 * FileName: UserController
 * Author:   kongfanyu
 * Date:     2020/9/13 09:54
 * http://localhost:8080/userInfo/10001
 */
@Controller
@RequestMapping("userInfo")
@CrossOrigin
public class UserController {

    @GetMapping("{id}")
    public ModelAndView findById(@PathVariable Integer id, HttpServletRequest request){
        System.out.println("请求方法:" + request.getMethod());
        UserInfo userInfo = new UserInfo();
        userInfo.setId(id);
        userInfo.setUsername("admin");
        userInfo.setPassword("123456");

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user");//视图View
        modelAndView.addObject("u",userInfo);//数据model

        return modelAndView;
    }

}
